/**
 * ContractMapper接口
 */
package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.dto.AddReservationDto;
import com.zzyl.dto.ReservationDto;
import com.zzyl.dto.TimeDto;
import com.zzyl.entity.Contract;
import com.zzyl.entity.Reservation;
import com.zzyl.vo.ContractVo;
import com.zzyl.vo.CountByTimeVo;
import com.zzyl.vo.ReservationVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ReservationMapper {
    @Select("select count(*) from reservation where create_by = #{id} and reservation.status = 2 and time between #{start} and #{end}")
    Long selectCancelCount(Long id, LocalDateTime start, LocalDateTime end);

    @Select("select count(*) count,time from reservation where type = 0 and status = 0 group by #{time}")
    List<CountByTimeVo> selectCountByTime(LocalDateTime time);

    void addReservation(Reservation reservation);


    Page<ReservationVo> selectAll(ReservationDto dto);

    @Update("update reservation set status = 2 where id = #{id}")
    void cancelReservation(Long id);

    @Select("select count(*) from reservation where time = #{time}")
    Integer selectCountByGivenTime(LocalDateTime time);
}

